function getQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.search.substr(1).match(reg);
	if (r != null)
		return unescape(r[2]);
	return null;
}
$("#messageBtn").click(function() {
	var messageTo = $.trim($('#clubName').val());
	var messageContent = $.trim($('#clubAbout').val());
	if (messageTo == "" || messageContent == "") {
		$('#error').text('信息不能为空').show();
		return;
	} else {
		$.ajax({
			url : localhost + "message/addMessage",
			dataType : "jsonp",
			data : {
				messageTo : messageTo,
				messageContent : messageContent
			},
			jsonp : "jsonpCallback",
			success : function(data) {
				if (data <= 0) {
					$("#error").html("*添加失败*");
				} else{
					$("#error").html("*添加成功成功*");
					window.location.href = "message.shtml";
				}
			}
		});
	}
});
$(document).ready(function() {
	var messageTo = getQueryString('messageTo');
	$('#clubName').val(messageTo);
});